import axios from 'axios'
// import qs from 'qs'

const axiosReq=axios.create({
    baseURL:'http://47.97.2.92:9091/mylafe-goventer',
    timeout:10000
})

export default {
    get:function(url,success){
        axiosReq.get(url).then((response)=>{
            let data=response.data;
            console.log(data)
            if (data.success){
                success(data.data)
            }
        }).catch(()=>{

        })
    },
    post:function (url,data,success) {
        axiosReq.post(url,data).then((response)=>{
            let data=response.data;
            if (data.success){
                success(data.data)
            }
        }).catch(()=>{

        })
    },
    postWithJson:function (url, obj, success) {
        // let formData=qs.stringify(obj, { allowDots: true })
        console.log(obj)
        axiosReq.post(url,obj,{
            headers: {
                'Content-Type': 'application/json'
            }
        }).then((response)=>{
            let data=response.data;
            if (data.success){
                success(data.data)
            }else {
                success(data.data)
            }
        }).catch((error)=>{
            console.log(error)
        })
    }

}
